﻿@model NTQOnlineExamFrontend.Models.CheckoutViewModel

@{
    ViewBag.Title = "Check out";
    Layout = "~/Views/Shared/_LayoutNoLeft.cshtml";
}
<div class="col-sm-8">
    <h3 class="headline first-child"><span>Billing to</span></h3>
    @using (Html.BeginForm("Checkout", "Basket", FormMethod.Post, new { model = Model, id = "checkout" }))
    {
        @Html.AntiForgeryToken()    
        @Html.ValidationSummary(true)
        @Html.HiddenFor(model => model.Email)
        <div class="form-group">
            <div class="row">
                <div class="col-sm-6">
                    @Html.LabelFor(model => model.FirstName)
                    @Html.TextBoxFor(model => model.FirstName, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.FirstName)

                </div>
                <div class="col-sm-6">
                    @Html.LabelFor(model => model.LastName)
                    @Html.TextBoxFor(model => model.LastName, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.LastName)
                </div>
            </div>
        </div>
        <div class="form-group">
            @Html.LabelFor(model => model.BillingAddress)
            @Html.TextBoxFor(model => model.BillingAddress, new { @class = "form-control" })
            @Html.ValidationMessageFor(model => model.BillingAddress)
        </div>
        <div class="form-group">
            <div class="row">
                <div class="col-sm-6">
                    @Html.LabelFor(model => model.BillingZipCode)
                    @Html.TextBoxFor(model => model.BillingZipCode, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.BillingZipCode)

                </div>
                <div class="col-sm-6">
                    @Html.LabelFor(model => model.BillingPOBox)
                    @Html.TextBoxFor(model => model.BillingPOBox, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.BillingPOBox)
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="row">
                <div class="col-sm-6">
                    @Html.LabelFor(model => model.BillingCity)
                    @Html.TextBoxFor(model => model.BillingCity, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.BillingCity)

                </div>
                <div class="col-sm-6">
                    @Html.LabelFor(model => model.BillingCountry)
                    @Html.TextBoxFor(model => model.BillingCountry, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.BillingCountry)
                </div>
            </div>
        </div>
        <div class="controls">
            @if (!Model.CanCheckout)
            {
                <button class="btn btn-red" disabled="disabled" type="submit">Checkout</button>
            }
            else
            {
                <button class="btn btn-red" type="submit">Checkout</button>
            }
            <button class="btn btn-red" onclick="backToBasket();" type="button">Back</button>

        </div>
    }
</div>

<script type="text/javascript">
    function backToBasket() {
        window.location.href = '@Url.RouteUrl(new { Controller = "Basket", Action = "GetUserBasket" })';

    };
   
    var BasketClient = new function () {
        this.OnSuccessed = function (response) {

            //if (!response.IsError && response.Data.Success) {
            //    alert("OK");
            //    //     Feedback.ShowInfoWithFadeOut("Data saved successfully.");
            //}
            //else
            //    Feedback.ShowError(response.Object);
        };

        this.OnFailed = function (jsonData) {

        };
    };
</script>
